<?php

namespace app\admin\model\service;

use think\Model;


class User extends Model
{

    

    

    // 表名
    protected $name = 'service_user_info';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'is_skill_text',
        'is_shop_text',
        'is_plus_text',
        'is_update_text',
        'plustime_text'
    ];
    

    
    public function getIsSkillList()
    {
        return ['0' => __('Is_skill 0'), '1' => __('Is_skill 1')];
    }

    public function getIsShopList()
    {
        return ['0' => __('Is_shop 0'), '1' => __('Is_shop 1')];
    }

    public function getIsPlusList()
    {
        return ['0' => __('Is_plus 0'), '1' => __('Is_plus 1')];
    }

    public function getIsUpdateList()
    {
        return ['0' => __('Is_update 0'), '1' => __('Is_update 1')];
    }


    public function getIsSkillTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_skill']) ? $data['is_skill'] : '');
        $list = $this->getIsSkillList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsShopTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_shop']) ? $data['is_shop'] : '');
        $list = $this->getIsShopList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsPlusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_plus']) ? $data['is_plus'] : '');
        $list = $this->getIsPlusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsUpdateTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_update']) ? $data['is_update'] : '');
        $list = $this->getIsUpdateList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getPlustimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['plustime']) ? $data['plustime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    protected function setPlustimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


}
